{include file='common/_meta' /}
<style>
.classbtn{
    display: inline-block;
    background: #009688;
    height: 25px;
    line-height: 25px;
    padding: 0 5px;
    color: #fff;
    border-radius: 5px
}
</style>
<body id="iosiframe">
<div class="container">

    <div class="layui-row">
        <div class="layui-col-md12 breadcrumb">
            <span class="layui-breadcrumb">
                <a><cite>财务管理</cite></a>
                <a><cite>短信充值</cite></a>
            </span>
        </div>
    </div>

    <div class="layui-row">

      <form class="layui-form" action="" lay-filter="" style="padding-top: 15px;">


        <div class="layui-col-sm12">
            <div class="layui-form-item">
                <div class="layui-input-block" style="margin-left: 0;">
                    <h2>账户余额：{$infoData.oevrplus}</h2>
                </div>
            </div>
        </div>
        {if condition="session('user_type') == 'admin' || (session('user_type') == 'channel' && in_array(session('channel_level'),[1,2,4])) "}
        <div class="layui-col-sm4">
            <div class="layui-form-item">
                <div class="layui-input-block" style="margin-right: 50px;margin-left: 0;">
                    <select name="cha" lay-search>
                        <option value="">搜索用户</option>
                        {volist name='channels' id='c'}
                        <option value="{$c.channel_id}"> {$c.company_name}({$c.channel_id})</option>
                        {/volist}
                    </select>
                </div>
            </div>
        </div>

        <div class="layui-col-sm3">
            <div class="layui-input-block" style="margin-right: 50px;margin-left: 0;">
                <button class="layui-btn custom-sm-fluid" lay-submit lay-filter="custom-search">搜索</button>
            </div>
        </div>

        {/if}

      </form>
    </div>
    <p style = "padding:10px 0;">【说明】<i class="layui-icon layui-icon-add-circle-fine"></i> : 短信充值 ；<i class="layui-icon layui-icon-rmb"></i> : 单价调整 ；<i class="layui-icon layui-icon layui-icon-return"></i> : 短信退款 </p>

  <div class="layui-col-md12">

    <table class="layui-hide" id="initdate" lay-filter="datatable"></table>

    <script type="text/html" id="barDemo">

        <a class="classbtn" onclick="layer_open('短信充值', '{:url('BalanceShift/recharge_add')}' + '?channel_id=' + {{ d.channel_id }})"  title="短信充值"><i class="layui-icon layui-icon-add-circle-fine"></i></a>

        <!-- <a class="classbtn" onclick="layer_open('单价调整', '{:url('BalanceShift/recharge_adjust')}' + '?channel_id=' + {{ d.channel_id }})" title="单价调整"><i class="layui-icon layui-icon-rmb"></i></a> -->

        <a class="classbtn" style="background:#FF5722" onclick="layer_open('短信退款', '{:url('BalanceShift/recharge_refund')}' + '?channel_id=' + {{ d.channel_id }})" title="短信退款"><i class="layui-icon layui-icon-return"></i></a>

    </script>

  </div>

</div>
{include file="common/_footer"}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
layui.use('table', function() {

  var table = layui.table;
  var layer = layui.layer;
  var form  = layui.form;

    var tableIns = table.render({
        elem: '#initdate'
        ,url:'{:url('BalanceShift/index')}'
        ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
        ,method:'post'//请求方式
        ,where: {api: 1}
        ,page:true//开启分页
        ,limit:15//每页记录数
        ,limits: [15,20,30,40,50,60,70,80,90]
        ,cols: [{$configTable|raw}]
    });

    // 监听搜索事件
    form.on('submit(custom-search)', function(data) {

        tableIns.reload({
            where: {cha: data.field.cha ,api: 1 }
            ,page: {curr: 1 }
        });

        $(window).resize()

        return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
    });

    /*解决操作按钮收缩，打开tips框不生效问题 start*/
    $(document).off('mousedown', '.layui-table-grid-down').on('mousedown', '.layui-table-grid-down', function (even) {

        table._tableTrCurr = $(this).closest('td');
    });

    $(document).off('click', '.layui-table-tips-main [lay-event]').on('click', '.layui-table-tips-main [lay-event]', function (even) {

        var elem = $(this);
        var tableTrCurr = table._tableTrCurr;

        if (!tableTrCurr) {

            return;
        }

        var layerIndex = elem.closest('.layui-table-tips').attr('times');
        layer.close(layerIndex);

        table._tableTrCurr.find('[lay-event="' + elem.attr('lay-event') + '"]').first().click();
    });
    /*解决操作按钮收缩，打开tips框不生效问题 end*/

});

function layer_open($title, $url) {

    layer.open({
        type: 2,
        title: $title,
        area: ['100%', '100%'],
        content: $url
    });
}

//清款
function qingkuang(cid)
{
    layer.confirm('你将进行清款操作，该操作将清除redis上的余额！', {icon: 0, title:'提示'}, function(index){
        layer.close(index);

        layer.confirm('将清除渠道'+cid+'-Redis上的余额！', {icon: 0, title:'提示'}, function(index){
            layer.close(index);

            var indexload = layer.load();

            $.post('{:url('BalanceShift/clearRedisMoney')}', {cid:cid} ,function(m){

                layer.close(indexload);

                if(m.code == 1)
                {
                    layer.alert("清除成功");
                }else{
                    layer.alert("清除失败");
                }
            })

        });

    });
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>